// 1997 North America - Mid-Central USA, POJ1562 - Oil Deposits
// 陈锋
#include <cstdio>
#include <cstring>
const int NN = 100 + 4;
char pic[NN][NN];
int M, N, C[NN][NN];
#define _for(i, a, b) for (int i = (a); i < (b); ++i)

void dfs(int r, int c, int id) {
  if (r < 0 || r >= M || c < 0 || c >= N) return;
  if (C[r][c] > 0 || pic[r][c] != '@') return;
  C[r][c] = id;
  for (int dr = -1; dr <= 1; dr++)
    for (int dc = -1; dc <= 1; dc++)
      if (dr != 0 || dc != 0) dfs(r + dr, c + dc, id);
}

int main() {
  while (scanf("%d%d", &M, &N) == 2 && M && N) {
    _for(i, 0, M) scanf("%s", pic[i]);
    memset(C, 0, sizeof(C));
    int cnt = 0;
    _for(i, 0, M) _for(j, 0, N) if (C[i][j] == 0 && pic[i][j] == '@')
        dfs(i, j, ++cnt);
    printf("%d\n", cnt);
  }
  return 0;
}
/*
算法分析请参考: 《入门经典-第2版》例题6-12
注意如何用简短的代码遍历每个点的8个邻居
*/
// Accepted 380kB 939 G++2020-12-13 20:07:55 22207902